<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
			<div class="btn-group" data-toggle="buttons">
				<label class="btn btn-primary active" id="paperBtn">
					<input type="radio" name="paperBtn" >公告
				</label>
				<label class="btn btn-primary" id="departmentPaperBtn">
					<input type="radio" name="departmentPaperBtn"> 所属部门公告
				</label>
			</div>
			<!--第一部分内容  -->
			<div class="row">
				<div class="col-xs-12">
					<div class="box">
						<div class="box-content no-padding">
							<table
								class="table table-bordered table-striped table-hover table-heading table-datatable"
								id="datatable-1">
								<thead>
									
								</thead>
								<tbody>																	
								</tbody>
							</table>
						</div>
					</div>
				</div>
			</div>
			<!-- 第一部分内容 -->
<script type="text/javascript">
$(document).ready(function(){
	$("#announcement").addClass("active");
	$("#announcement").addClass("active-parent");
	$("#announcement ul li:first-child").addClass("active");
	$("#announcement").find("ul").show();
	function allPaper(){
		$("thead").empty();
		$("tbody").empty();
			var thead="<tr>"+
				"<th>#</th>"+
				"<th>标题</th>"+
				"<th>内容</th>"+
				"<th>创建者</th>"+
				"<th>发布部门</th>"+
				"<th>发布时间</th>"+
			"</tr>";
			$("thead").append(thead);
			$.ajax({
				url:"getPaper",
				type:"get",
				dataType:"json",
				success:function(json){
					$.each(json,function(index,c){	
						index+=1;
						var line="<tr>"+
							"<td>"+index+"</td>"+
							"<td><a href='#' id='paperDetail' data-paperId='"+c.id+"'>"+c.title+"</a></td>"+
							"<td>"+c.content+"</td>"+
							"<td>"+c.creator+"</td>"+
							"<td>"+c.department+"</td>"+
							"<td>"+c.createTime+"</td>"+
							"</tr>";
						$("tbody").append(line);
					});
				}
			})
		}
	function departmentPaper(){
		$("thead").empty();
		$("tbody").empty();
		var thead="<tr>"+
			"<th>#</th>"+
			"<th>标题</th>"+
			"<th>内容</th>"+
			"<th>创建者</th>"+
			"<th>发布部门</th>"+
			"<th>发布时间</th>"+
		"</tr>";
		$("thead").append(thead);
		$.ajax({
			url:"getPaper",
			data:{departmentId:${sessionScope.employee.departmentId}},
			type:"get",
			dataType:"json",
			success:function(json){
				$.each(json,function(index,c){
					index+=1;
					var line="<tr>"+
						"<td>"+index+"</td>"+
						"<td><a href='#' id='paperDetail' data-paperId='"+c.id+"'>"+c.title+"</a></td>"+
						"<td>"+c.content+"</td>"+
						"<td>"+c.creator+"</td>"+
						"<td>"+c.department+"</td>"+
						"<td>"+c.createTime+"</td>"+
						"</tr>";
					$("tbody").append(line);
				});
			}
		})
	}
	function getDetail(){
	
	}
	function showDetailList(id){
		$.ajax({
			url:"paperDetail",
			data:{id:id},
			type:"get",
			dataType:"json",
			success:function(json){
				$("thead").empty();
				$("thead").html(
						"<tr>"+
						"<th>#</th>"+
						"<th>标题</th>"+
						"<th>内容</th>"+
						"<th>创建者</th>"+
						"<th>发布部门</th>"+
						"<th>发布时间</th>"+
						"<th>审批者</th>"+
						"<th>审批时间</th>"+
					"</tr>"
				);
				$("tbody").html(
						"<tr>"+
						"<td>1</td>"+
						"<td>"+json.title+"</td>"+
						"<td>"+json.content+"</td>"+
						"<td>"+json.creator+"</td>"+
						"<td>"+json.department+"</td>"+
						"<td>"+json.createTime+"</td>"+
						"<td>"+json.approver+"</td>"+
						"<td>"+json.approveTime+"</td>"+
					"</tr>"
				)
			}	
		})
		
		
	}
	$("tbody").on("click","#paperDetail",function(e){
		var id=$(this).attr("data-paperId");
		e.preventDefault();
		showDetailList(id);
	});
	$("#paperBtn").click(function(){
		allPaper();
	});
	$("#departmentPaperBtn").click(function(){
		departmentPaper();
	});
	allPaper();
})
</script>